/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React, {useState} from 'react';
import {View, Text, TouchableOpacity, StyleSheet} from 'react-native';
import IM from './src/pages/IM/index.tsx';
import VideoList from './src/pages/VideoList/index.tsx';
import PlayList from './src/pages/PlayList/PlayListPage.tsx';
import {setBreakpoints} from '@hadss/react_native_adaptive_layout';

function App(): JSX.Element {
  /**
   * 修改横向md的断点区间定义，iOS16promax在直板机的时候宽度是956导致：
   * - xs: 0 < xs < 320
   * - sm: 320 <= sm < 600
   * - md: 600 <= md < 960
   * - lg: 960 <= lg < 1440
   * - xl: 1440 <= xl
   */
  setBreakpoints({
    md: 960,
  });
  const onPressLearnMore = (type: string): void => {
    setShowPage(type);
  };
  const [showPage, setShowPage] = useState('Home');
  const HomeScreen = (): JSX.Element => (
    <View style={styles.outBtn}>
      <TouchableOpacity
        onPress={(): void => {
          onPressLearnMore('IM');
        }}
        style={styles.botton}>
        <Text style={{color: '#fff'}}>IM</Text>
      </TouchableOpacity>
      <TouchableOpacity
        onPress={(): void => {
          onPressLearnMore('music');
        }}
        style={styles.botton}>
        <Text style={{color: '#fff'}}>音乐</Text>
      </TouchableOpacity>
      <TouchableOpacity
        onPress={(): void => {
          onPressLearnMore('video');
        }}
        style={styles.botton}>
        <Text style={{color: '#fff'}}>长视频</Text>
      </TouchableOpacity>
    </View>
  );

  return (
    <>
      {showPage === 'Home' && <View style={{height: 100}}></View>}
      {showPage === 'IM' && <IM changePage={setShowPage}></IM>}
      {showPage === 'video' && <VideoList changePage={setShowPage}></VideoList>}
      {showPage === 'music' && <PlayList changePage={setShowPage}></PlayList>}
      {showPage === 'Home' && <HomeScreen></HomeScreen>}
    </>
  );
}
const styles = StyleSheet.create({
  outBtn: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'flex-end',
    marginBottom: 44,
  },
  botton: {
    width: 289,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#0A59F7',
    height: 40,
    marginTop: 12,
    borderRadius: 20,
  },
});

export default App;
